﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphosData
{
    public enum Relation
    {
        MaidServant = 1,
        MaidServantOf = 2,

        Concubine = 3,
        ConcubineOf = 4,

        Apostle = 5,
        ApostleOf = 6,

        Disciple = 7,
        DiscipleOf = 8,

        GrandDaughter = 9,
        Grandson = 10,
        GrandMother = 11,
        GrandFather = 12,

        Unknown = 13,

        Daughter = 14,
        Son = 15,
        Mother = 16,
        Father = 17,

        Sister = 18,
        Brother = 19,

        Wife = 20,
        Husband = 21,

        Nephew = 22,
        Niece = 23,
        Uncle = 24,
        Aunt = 25,

        Family = 26,

		SonInLaw = 27,
		FatherInLaw = 28,
		MotherInLaw = 29,
		DaughterInLaw = 30
		

    }

    public enum VisualEdgeWeight
    {
        Major = 0,
        Greater = 1,
        Normal = 2,
        Lesser = 3,
        Minor = 4
    }
    public enum VisualEdgeType
    {
        Primary = 0,
        Secondary = 1
    }

    public static class BiblicalPeopleUtility
    {
        public static VisualEdgeWeight GetEdgeWeight(Relation relation)
        {
            switch (relation)
            {
                case Relation.Apostle:
                    return VisualEdgeWeight.Greater;

                case Relation.ApostleOf:
                    return VisualEdgeWeight.Greater;

                case Relation.Disciple:
                    return VisualEdgeWeight.Greater;

                case Relation.DiscipleOf:
                    return VisualEdgeWeight.Greater;

                case Relation.Concubine:
                    return VisualEdgeWeight.Minor;

                case Relation.ConcubineOf:
                    return VisualEdgeWeight.Minor;

                case Relation.Daughter:
                    return VisualEdgeWeight.Greater;

                case Relation.Father:
                    return VisualEdgeWeight.Greater;

                case Relation.Husband:
                    return VisualEdgeWeight.Major;

                case Relation.MaidServant:
                    return VisualEdgeWeight.Minor;

                case Relation.MaidServantOf:
                    return VisualEdgeWeight.Minor;

                case Relation.Mother:
                    return VisualEdgeWeight.Greater;

                case Relation.Son:
                    return VisualEdgeWeight.Greater;

                case Relation.Wife:
                    return VisualEdgeWeight.Major;

                case Relation.Family:
                    return VisualEdgeWeight.Lesser;

                default:
                    return VisualEdgeWeight.Normal;
            }

        }
        public static Relation GetTieBreaker(Relation rel1, Relation rel2)
        {
            return rel1 > rel2 ? rel1 : rel2;
        }
        public static Relation ConverseRelation(Gender gender, Relation relation)
        {
            switch (relation)
            {
                case Relation.Apostle:
                    return Relation.ApostleOf;
                case Relation.ApostleOf:
                    return Relation.Apostle;
                case Relation.Disciple:
                    return Relation.DiscipleOf;
                case Relation.DiscipleOf:
                    return Relation.Disciple;
                case Relation.Brother:
                    return gender == Gender.Male ? Relation.Brother : Relation.Sister;
                case Relation.Sister:
                    return gender == Gender.Male ? Relation.Brother : Relation.Sister;
                case Relation.Concubine:
                    return Relation.ConcubineOf;
                case Relation.ConcubineOf:
                    return Relation.Concubine;
                case Relation.Daughter:
                    return gender == Gender.Male ? Relation.Father : Relation.Mother;
                case Relation.Father:
                    return gender == Gender.Male ? Relation.Son : Relation.Daughter;
                case Relation.Grandson:
                    return gender == Gender.Male ? Relation.GrandFather : Relation.GrandMother;
                case Relation.GrandDaughter:
                    return gender == Gender.Male ? Relation.GrandFather : Relation.GrandMother;
                case Relation.GrandFather:
                    return gender == Gender.Male ? Relation.Grandson : Relation.GrandDaughter;
                case Relation.GrandMother:
                    return gender == Gender.Male ? Relation.Grandson : Relation.GrandDaughter;
                case Relation.Husband:
                    return Relation.Wife;
                case Relation.MaidServant:
                    return Relation.MaidServantOf;
                case Relation.MaidServantOf:
                    return Relation.MaidServant;
                case Relation.Mother:
                    return gender == Gender.Male ? Relation.Son : Relation.Daughter;
                case Relation.Son:
                    return gender == Gender.Male ? Relation.Father : Relation.Mother;
                case Relation.Wife:
                    return Relation.Husband;
                case Relation.Uncle:
                    return gender == Gender.Male ? Relation.Nephew : Relation.Niece;
                case Relation.Aunt:
                    return gender == Gender.Male ? Relation.Nephew : Relation.Niece;
                case Relation.Nephew:
                    return gender == Gender.Male ? Relation.Uncle : Relation.Aunt;
                case Relation.Niece:
                    return gender == Gender.Male ? Relation.Uncle : Relation.Aunt;
				case Relation.SonInLaw:
					return gender == Gender.Male ? Relation.FatherInLaw : Relation.MotherInLaw;
				case Relation.DaughterInLaw:
					return gender == Gender.Male ? Relation.FatherInLaw : Relation.MotherInLaw;
				case Relation.FatherInLaw:
					return gender == Gender.Male ? Relation.SonInLaw : Relation.DaughterInLaw;
				case Relation.MotherInLaw:
					return gender == Gender.Male ? Relation.SonInLaw : Relation.DaughterInLaw;
                case Relation.Family:
                    return Relation.Family;
                default:
                    return Relation.Unknown;
            }
        }
    }
}
